<template>
  <div>
    <div class="loginContainer">
      <form class="loginForm">
        <div class="form-signin-heading text-center">
          <h1 class="sign-title">{{$config.LoginPageTitle}}</h1>
        </div>
        <div class="login-wrap">
          <i-input size="large" v-model="userPhone" placeholder="请输入账号" class="userPhone" @keyup.enter.native="handleSubmit"></i-input>
          <div class="codeDiv">
            <i-input
              size="large"
              v-model="password"
              placeholder="密码"
              class="passWord"
              type="password"
              @keyup.enter.native="handleSubmit"
            ></i-input>
          </div>
          <div class="tip">{{tip}}</div>
          <i-button type="primary" size="large" long class="loginBtn" @click="handleSubmit">登录</i-button>
        </div>
      </form>
      <div class="record">
        powered by © {{$config.LoginPageFooterCompanyName}} {{$config.versionNumber}} | 
        <a target="_blank" href="http://www.beian.miit.gov.cn" style="color:#FFF;">粤ICP备001号-2</a>
      </div>

    </div>
  </div>
</template>

<script>
import { checkPhone } from "@/libs/util"
export default {
  data() {
    return {
      tip: "", // 错误提示
      userPhone: "", // 手机号码
      password: "",  // 密码
      LoginPageTitle: '',
    };
  },
  methods: {
    // 点击登录
    handleSubmit() {
      if(this.userPhone == ""){
        this.tip = "手机号码不能为空"
      }else {
        if(checkPhone(this.userPhone)){
          let phone = this.userPhone;
          let code = this.password;
          // TODO 获取登录接口
          // handleLogin({ phone, code }).then(res => {
          //   if (res.code == 200 || res.code == 201) {
          //     this.$Message.success({
          //       content: "登录成功",
          //       duration: 0.5,
          //       top: 50
          //     });
          //     setTimeout(() => {
          //       this.$router.push({
          //         name: this.$config.homeName
          //       });
          //     }, 500);
          //   } else {
          //     this.tip = res.msg;
          //     this.$router.push({
          //       name: "login"
          //     });
          //   }
          // });
          setTimeout(() => {
            this.$router.push({
              name: this.$config.homeName
            });
          }, 500);
        } else {
          this.tip = "请输入正确的手机号码";
        }
      }
    },
  }
};
</script>
<style lang="less" scoped>
@import "./login.less";
</style>

